package com.larry.rabbitmq.fifth;

import com.larry.rabbitmq.util.RabbitMQUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @author larry
 * @Title: larry-rabbitmq
 * @Package com.larry.rabbitmq.fifth
 * @Description: 发送消息
 * @date 6/30/2110:23 AM
 */
public class EmitLog {

    //交换机名字
    public static final String EXCHANGE_NAME = "logs";

    public static void main(String args[]) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();

        //声明一个交换机
        channel.exchangeDeclare(EXCHANGE_NAME, "fanout");

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish(EXCHANGE_NAME,"",null,message.getBytes());
            System.out.println("发出消息.....: " + message);
        }

    }

}
